<template>
  <view>
    <!-- 标题栏 -->
    <nav-custom :showSearch="false" :isHome="true"></nav-custom>

    <!-- img -->
    <view class="success-tip">
      <image class="play" mode="aspectFit" src="https://xecho.oss-cn-hangzhou.aliyuncs.com/blog/支付成功.png"></image>
    </view>
  </view>
</template>

<script>
// import socket from "@/utils/socket.js"
import { mapState } from 'vuex'
// import algorithm from "@/utils/algorithm.js"
export default {
  data() {
    return {
      order: {
        city: '',
        detail: '',
        phone: '',
        region: '',
        username: '',
        confirm: '0',
        address: '',
        orderlist: [],
        allPrice: 0,
        allNum: 0,
        deliveryTime:''
      }
    }
  },
  computed: {
    ...mapState({
      address: state => state.order.address,
      cartList: state => state.order.cartList,
      allInfo: state => state.order.allInfo,
      userid:state => state.user.userInfo.objectId
    }),
  },
  created() {
    // console.log(this.address);
    ({
      city: this.order.city,
      detail: this.order.detail,
      phone: this.order.phone,
      region: this.order.region,
      username: this.order.username,
      deliveryTime: this.order.deliveryTime
    } = this.address)
    ; ({
      allPrice: this.order.allPrice,
      allNum: this.order.allNum,
    } = this.allInfo)
    this.order.orderlist = this.cartList
    this.order.userid = this.userid
    this.order.address = `${this.order.city}${this.order.region}${this.order.detail}`
    this.$H.post('/1.1/classes/order', this.order)
    uni.showToast({
      title:'支付完成~'
    })
    // let orderId = algorithm()
    // socket.emit('orderMsg', { ...this.order, orderId })
    console.log(this.order)
  },
  methods: {
    backHome() {
      uni.navigateTo({
        url: '/pages/home/home'
      })
    },

  },
}
</script>

<style lang="scss" scoped>
.a {
  height: 400rpx;
  width: 100%;
  margin-bottom: 400rpx;
}

.play {
  width: 100%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
</style>